/*
 * clog_event.h
 *
 *  Created on: 2012-8-21
 *      Author: lin
 */

#ifndef CLOG_EVENT_H_
#define CLOG_EVENT_H_

#include "def/defs.h"
#include "clog_level.h"

typedef struct {
    const char *category_name;
    const char *file_name;
    const char *func;

    uint16_t category_name_len;
    uint16_t file_name_len;
    uint16_t func_len;

    uint32_t line;

    const char *str_format;
    va_list str_args;

    struct timeval time_stamp;
    time_t last_sec;
    struct tm local_time;

    char D_time_str[10 + 1 + 8 + 1]; /* YYYY-mm-dd HH:mm:ss */
    char time_str[MAXLEN_CFG_LINE + 1];
    size_t time_str_len;
    char *last_time_fmt;

    clog_level_t * level;
} clog_event_t;

static inline void clog_event_set(clog_event_t *event, const char *cname,
        uint16_t cnamelen, const char *fname, uint16_t fnamelen,
        const char *func, uint16_t funclen, uint32_t line,uint16_t level) {
    event->category_name = cname;
    event->category_name_len = cnamelen;
    event->file_name = fname;
    event->file_name_len = fnamelen;
    event->func = func;
    event->func_len = fnamelen;
    event->line = line;

    //event->level = level;
}

static inline void clog_event_set_format(clog_event_t *event,const char *strformat,va_list strargs){
    event->str_format = strformat;
    va_copy(event->str_args, strargs);
}
#endif /* CLOG_EVENT_H_ */
